<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form prependId="false">
            <p:panel header="Cadastro de Convênio">
                <h:inputHidden value="#{convenioMB.convenio.id}" id="id"/>
                <p:panelGrid columns="2">
                    <p:outputLabel  for="nome" value="Nome"/>
                    <p:inputText  label="nome" id="nome" value="#{convenioMB.convenio.nome}" />
                    <p:commandButton action="#{convenioMB.salvar}" update="@form"  value="Salvar"/>
                </p:panelGrid>
            </p:panel>
        
        <p:dataTable id="dados" var="con" value="#{convenioMB.convenios}">
                <p:column>
                    <f:facet name="header">ID</f:facet>#{con.id}
                </p:column>
                <p:column>
                    <f:facet name="header">Nome</f:facet>#{con.nome}
                </p:column>
                <p:column>
                <f:facet name="header">Ação</f:facet>
                <p:commandButton value="Editar" actionListener="#{convenioMB.editar(con)}" ajax="true" update="@form" />
                
                <p:commandButton value="Excluir" actionListener="#{convenioMB.apagar(con)}" ajax="true" update="dados" />
                </p:column>
            </p:dataTable>
            </h:form>
    </h:body>
</html>

